package com.manxi.task;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Set;

@Component
@Slf4j
public class SetmealTask {
    /**
     * 处理菜品redis缓存信息的方法
     */
//    @Scheduled(cron = "0 0/5 * * * ?") //每五分钟执行一次
//    @Scheduled(cron = "0 0 1 * * ?") //每天凌晨一点执行一次
    @Scheduled(cron = "0 0 0 ? * MON") //每周一凌晨1点执行一次
    @CacheEvict(cacheNames = "setmealCache", allEntries = true)
    public void clearSetmealCache() {
        log.info("处理套餐redis缓存信息:{}", LocalDateTime.now());
    }
}
